package hopital.orm;

import hopital.sql.SqlObject;
import hopital.sql.SqlQuery;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.List;

public class Service extends SqlObject{
    
    
    private int _patient ;
    private String _service,_etat;
    private double _prix;

    public String getService() {
        return _service;
    }

    public void setService(String _service) {
        this._service = _service;
    }

    public String getEtat() {
        return _etat;
    }

    public void setEtat(String _etat) {
        this._etat = _etat;
    }

    public double getPrix() {
        return _prix;
    }

    public void setPrix(double _prix) {
        this._prix = _prix;
    }
    
    
    public Service(int _id) {
        this._patient=_id;
    }



    
    public int getPatient() {
        return _patient;
    }



    public Service(int _patient,double _prix , String _service) {
        this._patient = _patient;
        this._service = _service;
        this._prix = _prix;
    }

   


    

    public Service() {
    }

    
    
    private Service(ResultSet _rs) throws SQLException {
       this(_rs.getInt("c_patient"), _rs.getInt("c_prix"), _rs.getString("c_service"));
       this._id=_rs.getInt("c_patient");
    }
    
    @Override
    public SqlQuery insert() {
        return new SqlQuery("");
    }

    @Override
    public SqlQuery update() {
        return insert();
    }

    @Override
    public SqlQuery delete() {
        return insert();
    }

    @Override
    public SqlQuery select() {
            return new SqlQuery("SELECT * FROM v_services WHERE c_patient=? AND c_etat IS NULL;",_patient);
    }

    @Override
    public List<Object> getTable(ResultSet _rs) throws Exception {
        List<Object> list=new ArrayList<>();
        while (_rs.next()) {            
            list.add(new Service(_rs));
        }
        return list;
    }
}
